package com.xzy.mybatis.cipher.config;

import com.xzy.mybatis.cipher.annotation.CustomCryptoStrategy;
import com.xzy.mybatis.cipher.annotation.EnableMybatisCipher;
import com.xzy.mybatis.cipher.support.DatasourceHolder;
import com.xzy.mybatis.cipher.support.crypto.MyCryptoStrategy;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author xzy.xiao
 * @since 2025/1/13  17:26
 */
@Configuration
@MapperScan(basePackages = {"com.xzy.mybatis.**.mapper"})
@EnableMybatisCipher(
        scanPackages = {"com.xzy.mybatis.cipher.entity"},
        customCryptoStrategies = {
                @CustomCryptoStrategy(name = "my_aes", clazz = MyCryptoStrategy.class)
        }
)
public class MybatisConfig {
    @Bean
    public DatasourceHolder datasourceHolder() {
        return () -> "db1";
    }
}
